﻿using System.Collections.Generic;
using System.Globalization;
using System;
using System.Collections;
using System.Data;
using System.Diagnostics;

public class CallProfiler {

    public CallProfiler() {}

    private long _startM;
    private DateTime _startT;
    private long _endM;
    private DateTime _endT;


    public void MarkStart() {
        this._startM = Environment.WorkingSet;
        this._startT = DateTime.UtcNow;
    }

    public void MarkStartAndDebug(string msg) {
        MarkStart();
        Console.WriteLine("====Start===:" + msg);
    }

    public void MarkEnd() {
        this._endM = Environment.WorkingSet;
        this._endT = DateTime.UtcNow;
    }

    public void MarkEndAndDebug(string msg) {
        MarkEnd();
        Console.WriteLine("====Start===:" + this.Render(msg));
    }

    public double MilliSeconds()
    {
        TimeSpan t = _endT.Subtract(_startT);
        return t.TotalMilliseconds;
    }

    private string Render(string msg) {
        TimeSpan t = _endT.Subtract(_startT);
        return msg + ": MEM: " + (_endM - _startM) + " TIME:" + this.MilliSeconds() + " ms";
    }

}
